<template>
  <div class="goods-cate-cascader">
    <!--
      由于我们想要让组件支持v-model指令，那么就需要定义value属性，和触发input事件，
      由于是props接收的父组件数据，那么就不能用v-model直接绑定了
     -->
    <div class="block">
      <span class="demonstration">hover 触发子菜单</span>
      <el-cascader
        :options="options"
        :props="{ expandTrigger: 'hover', label: 'cat_name', value: 'cat_id' }"
        @change="handleChange"
      ></el-cascader>
    </div>
  </div>
</template>

<script>
export default {
  name: 'GoodsCateCascader',
  data() {
    return {
      options: [],
    };
  },
  methods: {
    handleChange(value) {
      // console.log(value);
    },
  },
  async created() {
    const { data: res } = await this.__apis.goods.getCategoriesList({
      type: 3,
    });
    // console.log(res);
    if (res.meta.status === 200) {
      this.$message.success('获取成功');
      this.options = res.data;
      // console.log(this.options);
    }
  },
};
</script>

<style lang="less" scoped>
.goods-cate-cascader {
  display: inline-block;
  .el-cascader {
    width: 100%;
  }
}
</style>
